home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
os2
/
te2_134t.zip
/
TE2INST.003
/
PlayWAVs.scr
< prev
next >
Wrap
Text File
|
1997-07-03
|
5KB
|
118 lines
/* --------------------------------------------------------------------- */
/* PlayWAVs.scr - A TE/2 REXX Syntax Script */
/* Copyright 1994 by Oberon Software */
/* All rights reserved */
/* */
/* Notes: This sample script illustrates the use of: */
/* 1. The TE/2 PlayFile() function */
/* 2. The TE/2 PopupMenu() function */
/* 3. The use of REXXUTIL with TE/2 Scripts */
/* 4. Error handling in REXX Syntax TE/2 scripts */
/* */
/* Notes: If your MultiMedia SOUNDS directory is not C:\MMOS2\SOUNDS */
/* you will need to edit the 'SoundPath' variable at the */
/* beginning of this script. */
/* --------------------------------------------------------------------- */
/* Variables used ------------------------------------------------------ */
Soundpath = 'C:\MMOS2\SOUNDS' /* edit this if your system is different */
SoundFile. = ''
SoundFile.0 = 0
MnuTitle = 'Play WAV File'
MnuTop = 5
MnuLeft = 20
MnuAttr = 0x1f
MnuHiAttr = 0x71
MnuItem = ''
/* Load REXXUTIL Functions --------------------------------------------- */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/* Setup Error handling ------------------------------------------------ */
signal on error name errproc
/* Main Program -------------------------------------------------------- */
call SysFileTree SoundPath||'\*.WAV', 'SoundFile', 'F'
if SoundFile.0 = 0 then
say 'No WAV file present in directory ['SoundPath']'
else
call PlayFiles
exit 0
/* Subroutines --------------------------------------------------------- */
PlayFiles:
/* If SoundFile.0 is 9 or less we do a simple menu */
/* If it's greater than 9, we have to be tricky */
if SoundFile.0 <= 9 then
do
MnuItem = '/Quit/'
do i = 1 to SoundFile.0
MnuItem = MnuItem||substr(SoundFile.i,38)||'/'
end
k = 1
do forever
'PopupMenu("'MnuTitle'", "'MnuItem'", 'mnuTop', 'mnuLeft', 'mnuAttr', 'mnuHiAttr', 'k')'
k = rc
if k <= 1 then leave
j = k - 1
/* See comment below about this use of sprintf() */
'sprintf("[%lu", OpenDialog(6, 4, 11, 76, DLogNormAttr))'
h = substr(rc,2)
'StrPut(8, 6, DLogNormAttr, "Playing file: %s", "'substr(SoundFile.j,38)'")'
'PlayFile("'substr(SoundFile.j,38)'", 1)'
'CloseDialog('h')'
end
end
else
do
iFirst = 1
do forever
MnuItem = '/Quit/'
iLast = iFirst + 7
if iLast > SoundFile.0 then iLast = SoundFile.0
xLast = (iLast - iFirst) + 2
do i = iFirst to iLast
MnuItem = MnuItem||substr(SoundFile.i,38)||'/'
end
MnuItem = MnuItem||'More.../'
k = 1
do forever
'PopupMenu("'MnuTitle'", "'MnuItem'", 'mnuTop', 'mnuLeft', 'mnuAttr', 'mnuHiAttr', 'k')'
k = rc
if k <= 1 | k > xLast then leave
j = iFirst + (k - 2)
/* ---------------------------------------------------------- */
/* This use of sprintf() is to workaround REXX's handling of */
/* large, unsigned numbers such as the dialog handle. We */
/* 'fool' REXX into thinking that it's a string by prepending */
/* a bogus character to the number and then we remove it to */
/* make it numeric again. */
'sprintf("[%lu", OpenDialog(6, 4, 11, 76, DLogNormAttr))'
h = substr(rc,2)
/* ---------------------------------------------------------- */
'StrPut(8, 6, DLogNormAttr, "Playing file: %s", "'substr(SoundFile.j,38)'")'
'PlayFile("'substr(SoundFile.j,38)'", 1)'
'CloseDialog('h')'
end
if k <= 1 then leave
iFirst = iFirst + 8
if iFirst > SoundFile.0 then iFirst = 1
end
end
return
/* Error handler ------------------------------------------------------- */
errproc:
TE2rc = rc
say '!! Error in TE/2 call'
say 'rc =' TE2rc
say 'line number =' sigl
say 'instruction = ['sourceline(sigl)']'
exit 1